<template>
  <div class="headerWrap wrap">
    <h1 class="logobox">
      <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
    </h1>
    <ul class="navbox">
      <li
        :class="{ current: route.path == item.path }"
        @click="router.push(item.path)"
        v-for="item in routeList"
      >
        {{ item.name }}
      </li>
    </ul>
    <div class="searchbox">
      <input type="text" v-model="keyword" />
      <span>
        <img
          src="../assets/img/search.png"
          alt=""
          class="search-btn"
          @click="search"
        />
      </span>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { reactive, toRefs, ref } from "vue";
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();
const keyword = ref();
const routeList = [
  {
    path: "/home",
    name: "首页",
  },
  {
    path: "/good",
    name: "全部商品",
  },
  {
    path: "/free",
    name: "个人中心",
  },
  {
    path: "/order",
    name: "我的订单",
  },
  {
    path: "/user",
    name: "专属福利",
  },
];
const search = () => {
  router.push(`/good?keyword=${keyword.value}`);
};
</script>

<style lang="less" scoped>
.headerWrap {
  height: 118px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  .navbox {
    width: 500px;
    display: flex;
    justify-content: space-between;
    .current {
      color: #0a328e;
    }
  }
}
.searchbox {
  display: flex;
  input {
    width: 214px;
    height: 40px;
    border: 1px solid #dedede;
    border-radius: 20px 0 0 20px;
    box-sizing: border-box;
    padding-left: 19px;
    outline-style: none;
  }
  span {
    width: 50px;
    height: 40px;
    background: #0a328e;
    border-radius: 0px 20px 20px 0px;
    text-align: center;
    line-height: 40px;
  }
  .search-btn {
    width: 15px;
    height: 15px;
  }
}
</style>
